package com.hcbd.tdwt.ui.setting.xingyu.activity;

import android.annotation.SuppressLint;
import android.widget.Button;
import android.widget.EditText;

import com.hcbd.tdwt.R;
import com.hcbd.tdwt.base.BaseActivity;
import com.hcbd.tdwt.base.BeidouBoxParams;
import com.pangu.bdsdk2021.entity.extensionterminal.BDRNXInfo;
import com.pangu.bdsdk2021.entity.extensionterminal.CCRNSInfo;
import com.pangu.bdsdk2021.terminal.TerminalSendManager;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;


//rnss频度设置
@SuppressLint("NonConstantResourceId")
@EActivity(R.layout.activity_rnss_frequency_out)
public class RnssFrequencyActivity extends BaseActivity {
    @ViewById
    Button implementBtn;
    @ViewById
    EditText ggaET,gsvET,gllET,gsaET,rmcET,zdaET;
    @AfterViews
    protected void init() {
        initMsgRegister();
        if(BeidouBoxParams.isBoxConnectNormal){
            TerminalSendManager.getInstance().level_two_getCCRNQ();
        }

    }

    @Click
    void implementBtn() {
          String gga=getTextStr(ggaET);
          if("".equals(gga)){
              toast("请输入GAA频度");
              return;
          }
        String gsv=getTextStr(gsvET);
        if("".equals(gsv)){
            toast("请输入GSV频度");
            return;
        }
        String gll=getTextStr(gllET);
        if("".equals(gll)){
            toast("请输入GLL频度");
            return;
        }
        String gsa=getTextStr(gsaET);
        if("".equals(gsa)){
            toast("请输入GSA频度");
            return;
        }
        String rmc=getTextStr(rmcET);
        if("".equals(rmc)){
            toast("请输入RMC频度");
            return;
        }
        String zda=getTextStr(zdaET);
        if("".equals(zda)){
            toast("请输入ZDA频度");
            return;
        }
        CCRNSInfo ccrnsInfo=new CCRNSInfo();
        ccrnsInfo.GGA=Integer.parseInt(gga);
        ccrnsInfo.GLL=Integer.parseInt(gsv);
        ccrnsInfo.GSA=Integer.parseInt(gll);
        ccrnsInfo.GSV=Integer.parseInt(gsa);
        ccrnsInfo.RMC=Integer.parseInt(rmc);
        ccrnsInfo.ZDA=Integer.parseInt(zda);
        TerminalSendManager.getInstance().level_two_setCCRNS(ccrnsInfo);
    }


    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true, priority = 1)
    public void eventBus(BDRNXInfo bdrnxInfo){
        ggaET.setText(bdrnxInfo.GGA);
        gsvET.setText(bdrnxInfo.GSV);
        gllET.setText(bdrnxInfo.GLL);
        gsaET.setText(bdrnxInfo.GSA);
        rmcET.setText(bdrnxInfo.RMC);
        zdaET.setText(bdrnxInfo.ZDA);
        toast("加载成功！");
    }
    @Click
    void headLeft(){
        finish();
    }
}
